package com.xueyi.operations.controller.admin;

import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import com.xueyi.operations.controller.base.BOpMaterialGroupController;
import com.xueyi.operations.domain.dto.OpMaterialGroupDto;
import com.xueyi.operations.domain.query.OpMaterialGroupQuery;
import io.swagger.v3.oas.annotations.Operation;
import com.xueyi.common.security.annotation.AdminAuth;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List;

/**
 * 资料分类管理 | 管理端 业务处理
 *
 * @author lwb
 */
@AdminAuth
@RestController
@RequestMapping("/admin/materialgroup")
public class AOpMaterialGroupController extends BOpMaterialGroupController {

    @Override
    @GetMapping("/list")
    @Operation(summary = "查询资料分类列表")
    @PreAuthorize("@ss.hasAuthority('RD:operations:materialgroup:list')")
    public AjaxResult list(OpMaterialGroupQuery opMaterialGroup) {
        return super.list(opMaterialGroup);
    }

    @Override
    @GetMapping(value = "/{id}")
    @Operation(summary = "查询资料分类详细")
    @PreAuthorize("@ss.hasAuthority('RD:operations:materialgroup:single')")
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return super.getInfo(id);
    }

    @Override
    @PostMapping("/export")
    @Operation(summary = "资料分类导出")
    @PreAuthorize("@ss.hasAuthority('RD:operations:materialgroup:export')")
    @Log(title = "资料分类管理", businessType = BusinessType.EXPORT)
    public void export(HttpServletResponse response, OpMaterialGroupQuery opMaterialGroup) {
        super.export(response, opMaterialGroup);
    }

    @Override
    @PostMapping
    @Operation(summary = "资料分类新增")
    @PreAuthorize("@ss.hasAuthority('RD:operations:materialgroup:add')")
    @Log(title = "资料分类管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody OpMaterialGroupDto opMaterialGroup) {
        return super.add(opMaterialGroup);
    }

    @Override
    @PutMapping
    @Operation(summary = "资料分类修改")
    @PreAuthorize("@ss.hasAuthority('RD:operations:materialgroup:edit')")
    @Log(title = "资料分类管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody OpMaterialGroupDto opMaterialGroup) {
        return super.edit(opMaterialGroup);
    }

    @Override
    @DeleteMapping("/batch/{idList}")
    @Operation(summary = "资料分类批量删除")
    @PreAuthorize("@ss.hasAuthority('RD:operations:materialgroup:del')")
    @Log(title = "资料分类管理", businessType = BusinessType.DELETE)
    public AjaxResult batchRemove(@PathVariable List<Long> idList) {
        return super.batchRemove(idList);
    }
}
